﻿using Coldairarrow.Business.Backstage.BS_Specials;
using Coldairarrow.Entity.Backstage.BS_Specials;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Backstage.BS_Specials
{
    [Route("/Backstage/BS_Specials/[controller]/[action]")]
    public class BS_SpecialController : BaseApiController
    {
        #region DI

        public BS_SpecialController(IBS_SpecialBusiness bS_SpecialBus)
        {
            _bS_SpecialBus = bS_SpecialBus;
        }

        IBS_SpecialBusiness _bS_SpecialBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<BS_SpecialDTO>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _bS_SpecialBus.GetDataListAsync(input);
        }


        [HttpPost]
        [NoCheckJWT]
        public async Task<object> GetFrontDataList()
        {
            return await _bS_SpecialBus.GetFontListAsync();
        }


        [HttpPost]
        public async Task<BS_Special> GetTheData(IdInputDTO input)
        {
            return await _bS_SpecialBus.GetTheDataAsync(input.id);
        }

        /// <summary>
        /// 获取父级
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public List<BS_Special> GetPtList()
        {
            return _bS_SpecialBus.GetPList();
        }
        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(BS_Special data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _bS_SpecialBus.AddDataAsync(data);
            }
            else
            {
                await _bS_SpecialBus.UpdateDataAsync(data);
            }
        }

        /// <summary>
        /// 删除专题
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _bS_SpecialBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}